﻿using AutoTest.Business.Dto.UserInfo;
using AutoTest.Business.Model;
using AutoTest.Business.Vo.UserInfo;
using AutoTest.Business.Vo.UserPlanConfig;
using AutoTest.Domain.Entities;
using AutoTest.Domain.Enums;
using AutoTest.Framework.Exceptions;
using AutoTest.Framework.Pager;

namespace AutoTest.Business.IServices
{
    /// <summary>
    /// 用户服务
    /// </summary>
    public interface IUserService
    {
        /// <summary>
        /// 检查是否有此用户
        /// </summary>
        /// <param name="model"></param>
        /// <param name="updateUser"></param>
        /// <returns></returns>
        Task<UserInfo> CheckUserInfoAsync(OpenUserInfoModel model, bool updateUser);

        /// <summary>
        /// 登录，其实就是生成tkn并记录
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        Task<LoginUserVo> LoginUserAsync(UserInfo userInfo);

        #region 后台管理

        /// <summary>
        /// 分页搜索
        /// </summary>
        /// <param name="searchDto"></param>
        /// <returns></returns>
        Task<PagedList<UserInfoListVo>> PageSearchUserInfoListAsync(UserInfoPageSearchDto searchDto);
        /// <summary>
        /// 获取用户详情
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        /// <exception cref="BusinessException"></exception>
        Task<UserInfoDetailVo> GetUserInfoDetailAsync(long userid);
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="addDto"></param>
        /// <returns></returns>
        Task<UserInfoDetailVo> AddUserInfoAsync(UserInfoAddDto addDto);

        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="editDto"></param>
        /// <returns></returns>
        /// <exception cref="BusinessException"></exception>
        Task<UserInfoDetailVo> EditUserInfoAsync(long id, UserInfoAddDto editDto);

        /// <summary>
        /// 修改用户状态
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        /// <exception cref="BusinessException"></exception>
        Task<UserInfoDetailVo> ChangeUserStatusAsync(long userid, EnumStatus status);
        #endregion

        /// <summary>
        /// 添加用户方案配置
        /// </summary>
        /// <param name="addDto"></param>
        /// <returns></returns>
        Task AddUserPlanConfigAsync(UserPlanConfigAddDto addDto);

        /// <summary>
        /// 获取配置
        /// </summary>
        /// <param name="configId"></param>
        /// <returns></returns>
        Task<UserPlanConfigVo> GetUserPlanConfigAsync(long configId);
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="loginDto"></param>
        /// <returns></returns>
        Task<LoginUserVo> UserLoginAsync(UserLoginDto loginDto);

        /// <summary>
        /// 查询当前用户开通的产品
        /// </summary>
        /// <returns></returns>
        Task<UserProductVo> GetCurrentUserProductsAsync();

        /// <summary>
        /// 检查用户是否具有产品权限
        /// </summary>
        /// <param name="frontPath"></param>
        /// <returns></returns>
        Task CheckUserProductAsync(string frontPath);
    }
}
